<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>常用指令</title>
</head>
<body>
    <div id="app">
        <input type="text" v-model.number="price">
       <p>{{price|currency()}}</p>
        <p>{{now|dateFormatter()}}</p>
    </div>
    <script src="../vue.js"></script>
    <script>
        Vue.filter('currency',function(v){
            return v.toFixed(2)
        })
        new Vue({
            el:'#app',
            data:{
                price:100,
                now:new Date()
            },
            filters:{
                dateFormatter(v){
                    var year = (v).getFullYear()
                    var month = (v).getMonth()
                    var date = (v).getDate()
                    return year + '年' + month + '月' + date + '日'
                }
            }
        })
        
    </script>
</body>
</html>